<template>
    <div>
        <h3>添加</h3>
        <table class="table">
            <tbody>
                <tr>
                    <td>等级名称</td>
                    <td>
                        <input type="text" v-model="data.djmc"> 
                    </td>
                </tr>
          
                <tr>
                    <td>权益名称</td>
                    <td>
                        <span>
                            <input type="checkbox" v-for="m in qwe" :value="m"   v-model="we">{{qwe}}
                        </span>
                    </td>
                </tr>
       
           
                <tr>
                    <td>等级状态</td>
                    <td>
                        <input type="checkbox" value="true" v-model="data.djzt">选中表是启用未选中表示禁用
                    </td>
                </tr>
                <tr>
                    <td></td>
                    <td>
                        <input type="button" value="添加" @click="add">
                    </td>
                </tr>
            </tbody>
        </table>

    </div>
</template>

<script setup lang="ts">
import axios from 'axios';
import { ref } from 'vue';

const we=ref([])
const data=ref({
    "djid": 0,
  "djmc": "",
  "qymc": "",
  "djzt": true
})

const qwe =ref(["免费喝水","免费用纸","免费加油卡","打9折"])



 const add=()=>{
    data.value.qymc=we.value.toString();
    axios.post("https://localhost:7267/api/dj/hyadd",data.value).then(res=>{
        if(res.data>0){
            alert("添加成功");
            location.href ="/djxs"
        }else{
            alert("添加失败")
        }
    })
 }

</script>

<style scoped>

</style>